using System;
using System.Collections;
using System.Collections.Generic;
using Unity.Entities;
using UnityEngine;

namespace LS
{
    public abstract class BakerBase<TMonoBehaviour, TComponentData> : Baker<TMonoBehaviour>
        where TMonoBehaviour : MonoBehaviour
        where TComponentData : unmanaged, IComponentData
    {
        public override void Bake(TMonoBehaviour authoring)
        {
            Entity ent = GetEntity(TransformUsageFlags.Dynamic);
            AddComponent(ent, CreateComponent(authoring));
        }

        public virtual TComponentData CreateComponent(TMonoBehaviour authoring)
        {
            Type componentType = typeof(TComponentData);
            return (TComponentData)Activator.CreateInstance(componentType);
        }
    }
}
